<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  
  <title>探索在 Archlinux 下使用 wine 时偶尔提示未找到 wine-mono 的完美解决方案 | 四叶草</title>
  
  <meta name="keywords" content="archlinux,linux">
  
  
  <meta name="description" content="一个技术宅的技术分享">
  

  
  <link rel="alternate" href="/atom.xml" title="四叶草">
  

  <meta name="HandheldFriendly" content="True" />
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <!-- meta -->
  

  <!-- link -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
  
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.10.1/css/all.min.css">
  

  

  
    
<link rel="stylesheet" href="/style.css">

  

  <script>
    function setLoadingBarProgress(num) {
      document.getElementById('loading-bar').style.width=num+"%";
    }
  </script>

  
  
<meta name="generator" content="Hexo 4.2.1"><link rel="alternate" href="/atom.xml" title="四叶草" type="application/atom+xml">
</head>

<body>
  
  
  <header class="l_header material">
  <div id="loading-bar-wrapper">
    <div id="loading-bar" class="material"></div>
  </div>

	<div class='wrapper'>
		<div class="nav-main container container--flex">
      <a class="logo flat-box" href='/' >
        
          四叶草
        
      </a>
			<div class='menu navgation'>
				<ul class='h-list'>
          
  					
  						<li>
								<a class="nav flat-box" href="/"
                  
                  
                  id="home">
									<i class='fas fa-home fa-fw'></i>&nbsp;主页
								</a>
							</li>
      			
  						<li>
								<a class="nav flat-box" href="/categories/"
                  
                    rel="nofollow"
                  
                  
                  id="categories">
									<i class='fas fa-folder-open fa-fw'></i>&nbsp;分类
								</a>
							</li>
      			
  						<li>
								<a class="nav flat-box" href="/tags/"
                  
                    rel="nofollow"
                  
                  
                  id="tags">
									<i class='fas fa-hashtag fa-fw'></i>&nbsp;标签
								</a>
							</li>
      			
  						<li>
								<a class="nav flat-box" href="/archives/"
                  
                    rel="nofollow"
                  
                  
                  id="archives">
									<i class='fas fa-archive fa-fw'></i>&nbsp;归档
								</a>
							</li>
      			
      		
				</ul>
			</div>

			
				<div class="m_search">
					<form name="searchform" class="form u-search-form">
						<input type="text" class="input u-search-input" placeholder="搜索" />
						<i class="icon fas fa-search fa-fw"></i>
					</form>
				</div>
			
			<ul class='switcher h-list'>
				
					<li class='s-search'><a class="fas fa-search fa-fw" href='javascript:void(0)'></a></li>
				
				<li class='s-menu'><a class="fas fa-bars fa-fw" href='javascript:void(0)'></a></li>
			</ul>
		</div>

		<div class='nav-sub container container--flex'>
			<a class="logo flat-box"></a>
			<ul class='switcher h-list'>
				<li class='s-comment'><a class="flat-btn fas fa-comments fa-fw" href='javascript:void(0)'></a></li>
        
          <li class='s-toc'><a class="flat-btn fas fa-list fa-fw" href='javascript:void(0)'></a></li>
        
			</ul>
		</div>
	</div>
</header>
	<aside class="menu-phone">
    <header>
		<nav class="menu navgation">
      <ul>
        
          
            <li>
							<a class="nav flat-box" href="/"
                
                
                id="home">
								<i class='fas fa-clock fa-fw'></i>&nbsp;近期
							</a>
            </li>
          
            <li>
							<a class="nav flat-box" href="/categories/"
                
                  rel="nofollow"
                
                
                id="categories">
								<i class='fas fa-folder-open fa-fw'></i>&nbsp;分类
							</a>
            </li>
          
            <li>
							<a class="nav flat-box" href="/tags/"
                
                  rel="nofollow"
                
                
                id="tags">
								<i class='fas fa-hashtag fa-fw'></i>&nbsp;标签
							</a>
            </li>
          
            <li>
							<a class="nav flat-box" href="/archives/"
                
                  rel="nofollow"
                
                
                id="archives">
								<i class='fas fa-archive fa-fw'></i>&nbsp;归档
							</a>
            </li>
          
            <li>
							<a class="nav flat-box" href="/about/"
                
                  rel="nofollow"
                
                
                id="about">
								<i class='fas fa-info-circle fa-fw'></i>&nbsp;关于
							</a>
            </li>
          
       
      </ul>
		</nav>
    </header>
	</aside>
<script>setLoadingBarProgress(40);</script>



  <div class="l_body nocover">
    <div class='body-wrapper'>
      <div class='l_main'>
  

  <article id="post" class="post white-box article-type-post" itemscope itemprop="blogPost">
    


  <section class='meta'>
    
    
    <div class="meta" id="header-meta">
      
        
  
    <h1 class="title">
      <a href="/learn/wine-mono/">
        探索在 Archlinux 下使用 wine 时偶尔提示未找到 wine-mono 的完美解决方案
      </a>
    </h1>
  


      
      <div class='new-meta-box'>
        
          
        
          
            
  <div class='new-meta-item author'>
    
      <a href="/about" rel="nofollow">
        
          <i class="fas fa-user" aria-hidden="true"></i>
        
        <p>四叶草🍀</p>
      </a>
    
  </div>


          
        
          
            <div class="new-meta-item date">
  <a class='notlink'>
    <i class="fas fa-calendar-alt" aria-hidden="true"></i>
    <p>2020-05-12</p>
  </a>
</div>

          
        
          
            
  
  <div class='new-meta-item category'>
    <a href='/categories/%E6%8E%A2%E7%A9%B6%E5%AD%A6%E4%B9%A0/' rel="nofollow">
      <i class="fas fa-folder-open" aria-hidden="true"></i>
      <p>探究学习</p>
    </a>
  </div>


          
        
          
            

  <div class="new-meta-item markdown">
    
    
      <a href="https://github.com/fkxxyz/fkxxyz-blog-src/blob/master/source/_posts/learn/wine-mono.md" target="_blank" rel="nofollow noopener">
    
      <i class="fab fa-markdown"></i>
      <p>md源文档</p>
    </a>
  </div>



          
        
          
            

  <div class="new-meta-item download">
    
    
      <a href="https://github.com/fkxxyz/fkxxyz-blog-src/raw/master/source/_posts/learn/wine-mono.md" target="_blank" rel="nofollow noopener">
    
      <i class="fas fa-download"></i>
      <p>下载本文</p>
    </a>
  </div>



          
        
          
            
  
    <div class="new-meta-item browse busuanzi">
      <a class='notlink'>
        <i class="fas fa-eye" aria-hidden="true"></i>
        <p>
          <span id="busuanzi_value_page_pv">
            <i class="fas fa-spinner fa-spin fa-fw" aria-hidden="true"></i>
          </span>
        </p>
      </a>
    </div>
  


          
        
          
            

          
        
      </div>
      
        <hr>
      
    </div>
  </section>


    <section class="article typo">
      <div class="article-entry" itemprop="articleBody">
        <p>使用 archlinux 有一段日子了，发现有时候在使用 wine 的过程中，明明已经装了 wine-mono 这个包，但依然时常出现这个对话框，很恼火，是时候把这问题探究彻底了。</p>
<p><img src="/img/no-mono.png" alt="no-mono"></p>
<a id="more"></a>

<h2 id="问题描述"><a href="#问题描述" class="headerlink" title="问题描述"></a>问题描述</h2><p>我们知道，wine 的 mono 组件是.NET Framework的开源和跨平台实现，能够让 Wine 顺利运行很多 .NET应用程序。</p>
<p>出现上述对话框后，点击安装，虽然会自动从 wine 官网把 mono 组件下到 $WINEPREFIX 里面，也是可以用，但是下的很慢，耗费很多时间，而且用 .NET 程序用的少，有时候仅仅想测试一个 exe 程序，点取消的话，每次要 wine 一个程序的时候都会弹出这个，实在讨厌。</p>
<p>后来，我觉得最新版的 wine 没有 wine-stable 稳定，我自己从 aur 编译了 wine-stable 之后，开始次次出现以上对话框了，经过百度谷歌，搜到的全是解决别的问题，无奈之下只能自己动手丰衣足食。</p>
<h2 id="问题探究"><a href="#问题探究" class="headerlink" title="问题探究"></a>问题探究</h2><p>先看看 wine-mono 这个包包含什么。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pacman -Ql wine-mono</span><br></pre></td></tr></table></figure>

<p>根据输出结果看出，原来只包含一个文件，还带版本号 /usr/share/wine/mono/wine-mono-4.9.3.msi</p>
<p>emmmm，什么？带版本号？我想起这问题偶然出现，什么时候出现呢，就是升级系统的时候会偶尔出现。那么 wine 是如何找到这个文件，以确认 mono 存在性呢？难道是扫描 /usr/share/wine/mono/ 整个目录？那可以找到的啊。</p>
<p>根据这些线索，我猜测，wine 是根据绝对路径和带版本号的文件名寻找 mono 的，一旦所需要的 mono 版本，和系统中存在的 mono 版本不一样，就会出现那找不到的对话框。</p>
<p>如何验证这个猜想呢，我想到 grep -rn 这个在所有子目录里面查找匹配的功能，开始行动。</p>
<p>先查看 wine-stable 包含哪些文件</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pacman -Ql wine-stable</span><br></pre></td></tr></table></figure>

<p>根据输出结果，大概知道 wine 的文件集中在以下几个目录</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;usr&#x2F;lib&#x2F;wine</span><br><span class="line">&#x2F;usr&#x2F;lib32&#x2F;wine</span><br><span class="line">&#x2F;usr&#x2F;share&#x2F;wine</span><br></pre></td></tr></table></figure>

<p>还有很多细小的目录，直接搜会很麻烦。我想到一个方案，把以前编译好的 wine-stable 安装包解压到一个目录里面，集中搜索。说干就干！</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">mkdir /tmp/wine</span><br><span class="line">cd /tmp/wine</span><br><span class="line">tar xf ~/.cache/yay/wine-stable/wine-stable-4.0.2-1-x86_64.pkg.tar.xz</span><br><span class="line">ls</span><br></pre></td></tr></table></figure>

<p>然后开始搜索</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">grep -rn wine-mono</span><br></pre></td></tr></table></figure>

<p>几秒钟后，输出结果只有三行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">匹配到二进制文件 usr&#x2F;lib32&#x2F;wine&#x2F;appwiz.cpl.so</span><br><span class="line">匹配到二进制文件 usr&#x2F;lib&#x2F;wine&#x2F;appwiz.cpl.so</span><br><span class="line">.BUILDINFO:1138:installed &#x3D; wine-mono-4.9.2-1-any</span><br></pre></td></tr></table></figure>

<p>最后一行保存的是软件包的信息，wine 启动的过程中肯定是不会用的。那………重点研究下 usr/lib/wine/appwiz.cpl.so 这个文件好了</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">grep -a wine-mono usr/lib/wine/appwiz.cpl.so</span><br></pre></td></tr></table></figure>

<p>输出结果</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">2.47wine_gecko-2.47-x86_64.msigeckoMSHTMLGeckoUrlGeckoCabDir4.7.5wine-mono-4.7.5.msimonoDotnetMonoUrlMonoCabDir%s does not exist and could not be created: %s</span><br></pre></td></tr></table></figure>

<p>果然，包含了字符串 wine-mono-4.7.5.msi，也就是说，wine-stable 是依赖于 4.7.5 版本 wine-mono，而我系统里存在的是 wine-mono-4.9.3.msi，找不到很正常。</p>
<p>好的，现在做个实验，把 wine-mono-4.9.3.msi 复制为 wine-mono-4.7.5.msi，问题是不是解决了。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/share/wine/mono</span><br><span class="line">mv wine-mono-4.9.3.msi wine-mono-4.7.5.msi</span><br><span class="line">rm -rf ~/.wine</span><br><span class="line">winecfg</span><br></pre></td></tr></table></figure>

<p>发现，确实没再弹出那个对话框了，猜想成立！</p>
<p>终于找到原因了，接下来想想怎么完美解决这个问题吧。</p>
<h2 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h2><p>我想到几个方案来解决这个问题：</p>
<ol>
<li>安装旧版本的 wine-mono 的包。</li>
<li>更新 wine 到最新版本，确保所需的 mono 版本与官方仓库最新的 mono 的版本一致。</li>
<li>对 appwiz.cpl.so 这个文件进行二进制编辑，修改里面的版本号字符串。</li>
<li>把系统里的 wine-mono-4.9.3.msi 重命名 wine-mono-4.7.5.msi</li>
<li>创建符号链接解决这个问题。</li>
</ol>
<p>想出了这么多办法，逐一分析这些办法的利弊：</p>
<ol>
<li><strong>安装旧版本的 wine-mono 包</strong>：这需要降级软件包，需要用 downgrade，然后可以把 wine-mono 这个软件包设为忽略更新的包写到 pacman.conf 里，这样做的话，每次升级 wine-stable 都需要检查版本号手动装合适的 wine-mono，有些麻烦。</li>
<li><strong>更新 wine 到最新版本</strong>：我大量实践过程中，感觉 wine-stable 确实要稳定一些，最新版的虽然有新特性但是免不了很多 bug。而且，就算更新到最新，也会偶尔出现版本不匹配的问题。</li>
<li><strong>对 appwiz.cpl.so 这个文件进行二进制编辑</strong>：这个操作很骚，但是万一以后版本号长度不一样了，怎么办呢，而且每次更新都得改也很麻烦。</li>
<li><strong>重命名系统里的 wine-mono</strong>：这个操作会影响到系统里包含的文件，而每次升级之后，旧的 wine-mono 文件就不会被删掉，然后装上了新的，白白占用空间，每次来处理，也很麻烦。</li>
<li><strong>创建符号链接</strong>：创建符号链接，可谓是 linux 解决这类问题最妙的办法，直接将 wine-mono-4.9.3.msi 链接到 wine-mono-4.7.5.msi，非常方便，但是每次更新还是要过来处理，还是很麻烦。</li>
</ol>
<p>可见创建符号链接是目前最低成本的解决方法，那，有没有完美的解决方法呢？</p>
<h2 id="完美解决（已失效）"><a href="#完美解决（已失效）" class="headerlink" title="完美解决（已失效）"></a>完美解决（已失效）</h2><p>通过以上思考，我最需要的就是，更新后不需要手动去创建符号链接，用脚本自动实现更新后的解决版本不一致的问题。</p>
<p>每次更新后，更新什么？更新 wine-stable 或 wine-mono 的时候。</p>
<p>如何在每次更新这两个包，触发调用脚本呢？利用包管理器的 <a href="https://wiki.archlinux.org/index.php/Pacman_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)#Hooks" target="_blank" rel="noopener">hook</a> 功能。</p>
<p>看来完美的解决方案是存在的，下面来列出，需要解决的几个子问题：</p>
<ol>
<li>脚本如何读取 appwiz.cpl.so 这个文件来获取所需的版本号呢？</li>
<li>脚本如何确定当前系统存在的 wine-mono 的版本号对应的文件呢？</li>
<li>升级后旧版本留下的符号链接会多余存在很多垃圾要怎么办呢？</li>
</ol>
<p>然后这些问题逐一得到解决：</p>
<ol>
<li><p>直接利用正则表达式匹配</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sed -n 's/.*\(wine-mono-[[:digit:].]\+.msi\).*/\1/p' /usr/lib/wine/appwiz.cpl.so</span><br></pre></td></tr></table></figure>

<p>输出结果为 wine-mono-4.7.5.msi</p>
</li>
<li><p>直接用包管理器查询包含的文件，然后正则匹配到具体文件名</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pacman -Qlq wine-mono | grep -o 'wine-mono-\([[:digit:].]\+\).msi'</span><br></pre></td></tr></table></figure>

<p>输出结果为 wine-mono-4.9.3.msi</p>
</li>
<li><p>每次更新后，先将 /usr/share/wine/mono 里的符号链接全删了，再建立即可。</p>
</li>
</ol>
<p>将以上思路进行具体实施，写成 <a href="https://wiki.archlinux.org/index.php/Pacman_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)#Hooks" target="_blank" rel="noopener">hook</a> 脚本，得到完美解决。具体 hook 的写法参见 <a href="https://jlk.fjfi.cvut.cz/arch/manpages/man/alpm-hooks.5" target="_blank" rel="noopener">alpm-hooks文档</a> 。</p>
<p>在 /etc/pacman.d/hooks 里面新建一个文件 wine-mono-version-fix.hook</p>
<p>里面写入</p>
<figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">[Trigger]</span></span><br><span class="line"><span class="attr">Type</span> = File</span><br><span class="line"><span class="attr">Operation</span> = Install</span><br><span class="line"><span class="attr">Operation</span> = Upgrade</span><br><span class="line"><span class="attr">Target</span> = usr/lib/wine/appwiz.cpl.so</span><br><span class="line"><span class="attr">Target</span> = usr/share/wine/mo<span class="literal">no</span>/*</span><br><span class="line"></span><br><span class="line"><span class="section">[Action]</span></span><br><span class="line"><span class="attr">Description</span> = Fixing the version of wine-mo<span class="literal">no</span> file.</span><br><span class="line"><span class="attr">When</span> = PostTransaction</span><br><span class="line"><span class="attr">Exec</span> = /usr/bin/sh -c <span class="string">'find /usr/share/wine/mono -type l -exec unlink &#123;&#125; \; ; ln -sf "$(pacman -Qlq wine-mono | grep "wine-mono-\\([[:digit:].]\\+\\).msi")" "/usr/share/wine/mono/$(sed -n "s/.*\\(wine-mono-[[:digit:].]\\+.msi\\).*/\\1/p" /usr/lib/wine/appwiz.cpl.so)" 2&gt;/dev/null ; true'</span></span><br></pre></td></tr></table></figure>

<p>至此，完美解决，以后无论如何更新 wine 或 wine-mono，或者无论如何更换 wine 的版本，总是能找到对应的 wine-mono，也再也不会弹出那个对话框了。</p>
<p>后来发现 wine-gecko 也出了类似的情况，那么同理。</p>
<p>在 /etc/pacman.d/hooks 里面新建一个文件 wine-gecko-version-fix.hook</p>
<p>里面写入</p>
<figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">[Trigger]</span></span><br><span class="line"><span class="attr">Type</span> = File</span><br><span class="line"><span class="attr">Operation</span> = Install</span><br><span class="line"><span class="attr">Operation</span> = Upgrade</span><br><span class="line"><span class="attr">Target</span> = usr/lib/wine/appwiz.cpl.so</span><br><span class="line"><span class="attr">Target</span> = usr/share/wine/gecko/*</span><br><span class="line"></span><br><span class="line"><span class="section">[Action]</span></span><br><span class="line"><span class="attr">Description</span> = Fixing the version of wine-gecko file.</span><br><span class="line"><span class="attr">When</span> = PostTransaction</span><br><span class="line"><span class="attr">Exec</span> = /usr/bin/sh -c <span class="string">'find /usr/share/wine/gecko -type l -exec unlink &#123;&#125; \; ; ln -sf "$(pacman -Qlq wine-gecko | grep "wine.gecko-\\([-.[:digit:]]\\+\\)-x86_64.msi")" "/usr/share/wine/gecko/$(sed -n "s/.*\\(wine.gecko-[-.[:digit:]]\+-x86_64.msi\\).*/\\1/p" /usr/lib/wine/appwiz.cpl.so)" 2&gt;/dev/null ; ln -sf "$(pacman -Qlq wine-gecko | grep "wine.gecko-\\([-.[:digit:]]\\+\\)-x86.msi")" "/usr/share/wine/gecko/$(sed -n "s/.*\\(wine.gecko-[-.[:digit:]]\+-x86.msi\\).*/\\1/p" /usr/lib32/wine/appwiz.cpl.so)" 2&gt;/dev/null ; true'</span></span><br></pre></td></tr></table></figure>

<h2 id="后续完美解决"><a href="#后续完美解决" class="headerlink" title="后续完美解决"></a>后续完美解决</h2><p>上述方法成功维持了一段时间，但最近发现又蹦出那个对话框，上述方法失效了？经过探索发现，/usr/lib/wine/appwiz.cpl.so 这个文件已经被改动，里面的相关字符串已经成了 unicode 字符串，并且文件名多了个 -x86，例如：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wine-mono-5.0.0-x86.msi</span><br></pre></td></tr></table></figure>

<p>那么，根据这种情况改进一下即可解决。</p>
<ol>
<li><p>利用正则表达式匹配</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">strings -eb /usr/lib/wine/appwiz.cpl.so | sed -n 's/.*\(wine-mono-[-x[:digit:].]\+.msi\).*/\1/p'</span><br></pre></td></tr></table></figure>

<p>输出结果为 wine-mono-5.0.0-x86.msi</p>
</li>
<li><p>用包管理器查询包含的文件，然后正则匹配到具体文件名</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pacman -Qlq wine-mono | grep -o 'wine-mono-\([-x[:digit:].]\+\).msi'</span><br></pre></td></tr></table></figure>

<p>输出结果为 wine-mono-5.0.0.msi</p>
</li>
</ol>
<p>写成 hook 脚本 wine-mono-version-fix.hook</p>
<figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">[Trigger]</span></span><br><span class="line"><span class="attr">Type</span> = File</span><br><span class="line"><span class="attr">Operation</span> = Install</span><br><span class="line"><span class="attr">Operation</span> = Upgrade</span><br><span class="line"><span class="attr">Target</span> = usr/lib/wine/appwiz.cpl.so</span><br><span class="line"><span class="attr">Target</span> = usr/share/wine/mo<span class="literal">no</span>/*</span><br><span class="line"></span><br><span class="line"><span class="section">[Action]</span></span><br><span class="line"><span class="attr">Description</span> = Fixing the version of wine-mo<span class="literal">no</span> file.</span><br><span class="line"><span class="attr">When</span> = PostTransaction</span><br><span class="line"><span class="attr">Exec</span> = /usr/bin/sh -c <span class="string">'find /usr/share/wine/mono -type l -exec unlink &#123;&#125; \; ; ln -sf "$(pacman -Qlq wine-mono | grep "wine-mono-\\([-x[:digit:].]\\+\\).msi")" "/usr/share/wine/mono/$(strings -eb /usr/lib/wine/appwiz.cpl.so | sed -n "s/.*\\(wine-mono-[-x[:digit:].]\\+.msi\\).*/\\1/p")" 2&gt;/dev/null ; true'</span></span><br></pre></td></tr></table></figure>

<p>同理，gecko 也这样解决。</p>
<figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">[Trigger]</span></span><br><span class="line"><span class="attr">Type</span> = File</span><br><span class="line"><span class="attr">Operation</span> = Install</span><br><span class="line"><span class="attr">Operation</span> = Upgrade</span><br><span class="line"><span class="attr">Target</span> = usr/lib/wine/appwiz.cpl.so</span><br><span class="line"><span class="attr">Target</span> = usr/share/wine/gecko/*</span><br><span class="line"></span><br><span class="line"><span class="section">[Action]</span></span><br><span class="line"><span class="attr">Description</span> = Fixing the version of wine-gecko file.</span><br><span class="line"><span class="attr">When</span> = PostTransaction</span><br><span class="line"><span class="attr">Exec</span> = /usr/bin/sh -c <span class="string">'find /usr/share/wine/gecko -type l -exec unlink &#123;&#125; \; ; ln -sf "$(pacman -Qlq wine-gecko | grep "wine.gecko-\\([-.[:digit:]]\\+\\)-x86_64.msi")" "/usr/share/wine/gecko/$(strings -eb /usr/lib/wine/appwiz.cpl.so | sed -n "s/.*\\(wine.gecko-[-.[:digit:]]\+-x86_64.msi\\).*/\\1/p")" 2&gt;/dev/null ; ln -sf "$(pacman -Qlq wine-gecko | grep "wine.gecko-\\([-.[:digit:]]\\+\\)-x86.msi")" "/usr/share/wine/gecko/$(strings -eb /usr/lib32/wine/appwiz.cpl.so | sed -n "s/.*\\(wine.gecko-[-.[:digit:]]\+-x86.msi\\).*/\\1/p")" 2&gt;/dev/null ; true'</span></span><br></pre></td></tr></table></figure>

<p>最后，我将上述两个文件用 PKDBUILD 打包上传到 AUR，方便后续使用，包名为 <a href="https://aur.archlinux.org/packages/wine-mono-gecko-version-fix/" target="_blank" rel="noopener">wine-mono-gecko-version-fix</a></p>

      </div>
      
      
        <br>
        


  <section class='meta' id="footer-meta">
    <div class='new-meta-box'>
      
        
          <div class="new-meta-item date" itemprop="dateUpdated" datetime="2020-05-12T18:58:06+08:00">
  <a class='notlink'>
    <i class="fas fa-clock" aria-hidden="true"></i>
    <p>更新于 2020年5月12日</p>
  </a>
</div>

        
      
        
          
  
  <div class="new-meta-item meta-tags"><a class="tag" href="/tags/archlinux/" rel="nofollow"><i class="fas fa-tag" aria-hidden="true"></i><p>archlinux</p></a></div> <div class="new-meta-item meta-tags"><a class="tag" href="/tags/wine/" rel="nofollow"><i class="fas fa-tag" aria-hidden="true"></i><p>wine</p></a></div>


        
      
        
          
  <div class="new-meta-item share -mob-share-list">
  <div class="-mob-share-list share-body">
    
      
        <a class="-mob-share-qq" title="QQ好友" rel="external nofollow noopener noreferrer"
          
          href="http://connect.qq.com/widget/shareqq/index.html?url=https://www.fkxxyz.com/learn/wine-mono/&title=探索在 Archlinux 下使用 wine 时偶尔提示未找到 wine-mono 的完美解决方案 | 四叶草&summary=使用 archlinux 有一段日子了，发现有时候在使用 wine 的过程中，明明已经装了 wine-mono 这个包，但依然时常出现这个对话框，很恼火，是时候把这问题探究彻底了。
"
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/xaoxuu/assets@19.1.9/logo/128/qq.png">
          
        </a>
      
    
      
        <a class="-mob-share-qzone" title="QQ空间" rel="external nofollow noopener noreferrer"
          
          href="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=https://www.fkxxyz.com/learn/wine-mono/&title=探索在 Archlinux 下使用 wine 时偶尔提示未找到 wine-mono 的完美解决方案 | 四叶草&summary=使用 archlinux 有一段日子了，发现有时候在使用 wine 的过程中，明明已经装了 wine-mono 这个包，但依然时常出现这个对话框，很恼火，是时候把这问题探究彻底了。
"
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/xaoxuu/assets@19.1.9/logo/128/qzone.png">
          
        </a>
      
    
      
        <a class="-mob-share-weibo" title="微博" rel="external nofollow noopener noreferrer"
          
          href="http://service.weibo.com/share/share.php?url=https://www.fkxxyz.com/learn/wine-mono/&title=探索在 Archlinux 下使用 wine 时偶尔提示未找到 wine-mono 的完美解决方案 | 四叶草&summary=使用 archlinux 有一段日子了，发现有时候在使用 wine 的过程中，明明已经装了 wine-mono 这个包，但依然时常出现这个对话框，很恼火，是时候把这问题探究彻底了。
"
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/xaoxuu/assets@19.1.9/logo/128/weibo.png">
          
        </a>
      
    
  </div>
</div>



        
      
    </div>
  </section>


      
      
          <div class="prev-next">
              
                  <section class="prev">
                      <span class="art-item-left">
                          <h6><i class="fas fa-chevron-left" aria-hidden="true"></i>&nbsp;上一页</h6>
                          <h4>
                              <a href="/d/ssfconv/" rel="prev" title="fcitx 真的也可以这么美 —— 对 fcitx 使用搜狗皮肤的改进">
                                
                                    fcitx 真的也可以这么美 —— 对 fcitx 使用搜狗皮肤的改进
                                
                              </a>
                          </h4>
                          
                              
                              <h6 class="tags">
                                  <a class="tag" href="/tags/fcitx/"><i class="fas fa-tag fa-fw" aria-hidden="true"></i> fcitx</a> <a class="tag" href="/tags/%E8%BE%93%E5%85%A5%E6%B3%95/"><i class="fas fa-tag fa-fw" aria-hidden="true"></i> 输入法</a> <a class="tag" href="/tags/%E7%9A%AE%E8%82%A4/"><i class="fas fa-tag fa-fw" aria-hidden="true"></i> 皮肤</a>
                              </h6>
                          
                      </span>
                  </section>
              
              
                  <section class="next">
                      <span class="art-item-right" aria-hidden="true">
                          <h6>下一页&nbsp;<i class="fas fa-chevron-right" aria-hidden="true"></i></h6>
                          <h4>
                              <a href="/c/myde/" rel="prev" title="猜猜我最终选择了什么桌面环境">
                                  
                                      猜猜我最终选择了什么桌面环境
                                  
                              </a>
                          </h4>
                          
                              
                              <h6 class="tags">
                                  <a class="tag" href="/tags/archlinux/"><i class="fas fa-tag fa-fw" aria-hidden="true"></i> archlinux</a> <a class="tag" href="/tags/%E6%A1%8C%E9%9D%A2%E7%8E%AF%E5%A2%83/"><i class="fas fa-tag fa-fw" aria-hidden="true"></i> 桌面环境</a>
                              </h6>
                          
                      </span>
                  </section>
              
          </div>
      
    </section>
  </article>



  <!-- 显示推荐文章和评论 -->



  






<!-- 根据页面mathjax变量决定是否加载MathJax数学公式js -->



  <script>
    window.subData = {
      title: '探索在 Archlinux 下使用 wine 时偶尔提示未找到 wine-mono 的完美解决方案',
      tools: true
    }
  </script>


</div>
<aside class='l_side'>
  
    
    
      
      
        
          
          
        
          
          
        
          
          
        
          
          
            
              <section class='widget grid'>
  
<header class='material'>
  <div><i class="fas fa-map-signs fa-fw" aria-hidden="true"></i>&nbsp;&nbsp;站内导航</div>
  
</header>

  <div class='content material'>
    <ul class="grid navgation">
      
        <li><a class="flat-box" title="/" href="/"
          
          
          id="home">
          
            <i class="fas fa-clock fa-fw" aria-hidden="true"></i>
          
          近期文章
        </a></li>
      
        <li><a class="flat-box" title="/archives/" href="/archives/"
          
            rel="nofollow"
          
          
          id="archives">
          
            <i class="fas fa-archive fa-fw" aria-hidden="true"></i>
          
          文章归档
        </a></li>
      
        <li><a class="flat-box" title="/about/" href="/about/"
          
            rel="nofollow"
          
          
          id="about">
          
            <i class="fas fa-info-circle fa-fw" aria-hidden="true"></i>
          
          关于小站
        </a></li>
      
    </ul>
  </div>
</section>

            
          
        
          
          
        
          
          
        
          
          
        
          
          
        
      
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
            
              
  <section class='widget category'>
    
<header class='material'>
  <div><i class="fas fa-folder-open fa-fw" aria-hidden="true"></i>&nbsp;&nbsp;文章分类</div>
  
    <a class="rightBtn"
    
      rel="nofollow"
    
    
    href="/categories/"
    title="categories/">
    <i class="fas fa-expand-arrows-alt fa-fw"></i></a>
  
</header>

    <div class='content material'>
      <ul class="entry">
        
          <li><a class="flat-box" title="/categories/%E5%8E%9F%E5%88%9B%E5%BC%80%E5%8F%91/" href="/categories/%E5%8E%9F%E5%88%9B%E5%BC%80%E5%8F%91/"><div class='name'>原创开发</div><div class='badge'>(5)</div></a></li>
        
          <li><a class="flat-box" title="/categories/%E6%8E%A2%E7%A9%B6%E5%AD%A6%E4%B9%A0/" href="/categories/%E6%8E%A2%E7%A9%B6%E5%AD%A6%E4%B9%A0/"><div class='name'>探究学习</div><div class='badge'>(6)</div></a></li>
        
          <li><a class="flat-box" title="/categories/%E6%95%99%E7%A8%8B/" href="/categories/%E6%95%99%E7%A8%8B/"><div class='name'>教程</div><div class='badge'>(7)</div></a></li>
        
          <li><a class="flat-box" title="/categories/%E8%AE%B0%E5%BD%95/" href="/categories/%E8%AE%B0%E5%BD%95/"><div class='name'>记录</div><div class='badge'>(1)</div></a></li>
        
      </ul>
    </div>
  </section>


            
          
        
          
          
        
          
          
        
          
          
        
      
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
            
              
  <section class='widget tagcloud'>
    
<header class='material'>
  <div><i class="fas fa-tags fa-fw" aria-hidden="true"></i>&nbsp;&nbsp;热门标签</div>
  
    <a class="rightBtn"
    
      rel="nofollow"
    
    
    href="/tags/"
    title="tags/">
    <i class="fas fa-expand-arrows-alt fa-fw"></i></a>
  
</header>

    <div class='content material'>
      <a href="/tags/archlinux/" style="font-size: 24px; color: #555">archlinux</a> <a href="/tags/fcitx/" style="font-size: 16.5px; color: #888">fcitx</a> <a href="/tags/hexo/" style="font-size: 16.5px; color: #888">hexo</a> <a href="/tags/linux/" style="font-size: 19px; color: #777">linux</a> <a href="/tags/php/" style="font-size: 14px; color: #999">php</a> <a href="/tags/python/" style="font-size: 21.5px; color: #666">python</a> <a href="/tags/rime/" style="font-size: 14px; color: #999">rime</a> <a href="/tags/sed/" style="font-size: 14px; color: #999">sed</a> <a href="/tags/shell/" style="font-size: 14px; color: #999">shell</a> <a href="/tags/wine/" style="font-size: 16.5px; color: #888">wine</a> <a href="/tags/%E4%BF%A1%E6%81%AF%E5%AE%89%E5%85%A8/" style="font-size: 16.5px; color: #888">信息安全</a> <a href="/tags/%E5%89%8D%E7%AB%AF/" style="font-size: 14px; color: #999">前端</a> <a href="/tags/%E5%8D%B3%E5%85%B4%E4%BC%B4%E5%A5%8F/" style="font-size: 14px; color: #999">即兴伴奏</a> <a href="/tags/%E5%8F%8C%E6%98%BE%E5%8D%A1%E5%88%87%E6%8D%A2/" style="font-size: 14px; color: #999">双显卡切换</a> <a href="/tags/%E5%92%8C%E5%BC%A6/" style="font-size: 14px; color: #999">和弦</a> <a href="/tags/%E6%80%9D%E7%BB%B4%E5%AF%BC%E5%9B%BE/" style="font-size: 16.5px; color: #888">思维导图</a> <a href="/tags/%E6%A1%8C%E9%9D%A2%E7%8E%AF%E5%A2%83/" style="font-size: 14px; color: #999">桌面环境</a> <a href="/tags/%E7%9A%AE%E8%82%A4/" style="font-size: 14px; color: #999">皮肤</a> <a href="/tags/%E8%BE%93%E5%85%A5%E6%B3%95/" style="font-size: 16.5px; color: #888">输入法</a> <a href="/tags/%E9%9F%B3%E4%B9%90/" style="font-size: 14px; color: #999">音乐</a>
    </div>
  </section>


            
          
        
          
          
        
          
          
        
      
        
          
          
        
          
          
        
          
          
            
              
  <section class='widget toc-wrapper'>
    
<header class='material'>
  <div><i class="fas fa-list fa-fw" aria-hidden="true"></i>&nbsp;&nbsp;本文目录</div>
  
    <!-- <div class='wrapper'><a class="s-toc rightBtn" rel="external nofollow noopener noreferrer" href="javascript:void(0)"><i class="fas fa-thumbtack fa-fw"></i></a></div> -->
  
</header>

    <div class='content material'>
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#问题描述"><span class="toc-text">问题描述</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#问题探究"><span class="toc-text">问题探究</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#解决方案"><span class="toc-text">解决方案</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#完美解决（已失效）"><span class="toc-text">完美解决（已失效）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#后续完美解决"><span class="toc-text">后续完美解决</span></a></li></ol>
    </div>
  </section>


            
          
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
        
      
    

  
</aside>

<footer id="footer" class="clearfix">
  
  
    <div class="social-wrapper">
      
        
          <a href="/atom.xml"
            class="social fas fa-rss flat-btn"
            target="_blank"
            rel="external nofollow noopener noreferrer">
          </a>
        
      
        
          <a href="mailto:fkxxyz@163.com"
            class="social fas fa-envelope flat-btn"
            target="_blank"
            rel="external nofollow noopener noreferrer">
          </a>
        
      
        
          <a href="https://github.com/fkxxyz"
            class="social fab fa-github flat-btn"
            target="_blank"
            rel="external nofollow noopener noreferrer">
          </a>
        
      
        
          <a href="https://ti.qq.com/open_qq/index2.html?url=mqqapi%3a%2f%2fuserprofile%2ffriend_profile_card%3fsrc_type%3dweb%26version%3d1.0%26source%3d2%26uin%3d396519827"
            class="social fab fa-qq flat-btn"
            target="_blank"
            rel="external nofollow noopener noreferrer">
          </a>
        
      
    </div>
  
  <br>
  <div><p>博客内容遵循 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" target="_blank" rel="noopener">署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议</a></p>
</div>
  <div>
    本站使用
    <a href="https://xaoxuu.com/wiki/material-x/" target="_blank" class="codename">Material X</a>
    作为主题
    
      ，
      总访问量为
      <span id="busuanzi_value_site_pv"><i class="fas fa-spinner fa-spin fa-fw" aria-hidden="true"></i></span>
      次
    
    。
  </div>
</footer>
<script>setLoadingBarProgress(80);</script>


      <script>setLoadingBarProgress(60);</script>
    </div>
    <a class="s-top fas fa-arrow-up fa-fw" href='javascript:void(0)'></a>
  </div>
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script>

  <script>
    var GOOGLE_CUSTOM_SEARCH_API_KEY = "";
    var GOOGLE_CUSTOM_SEARCH_ENGINE_ID = "";
    var ALGOLIA_API_KEY = "";
    var ALGOLIA_APP_ID = "";
    var ALGOLIA_INDEX_NAME = "";
    var AZURE_SERVICE_NAME = "";
    var AZURE_INDEX_NAME = "";
    var AZURE_QUERY_KEY = "";
    var BAIDU_API_ID = "";
    var SEARCH_SERVICE = "hexo" || "hexo";
    var ROOT = "/"||"/";
    if(!ROOT.endsWith('/'))ROOT += '/';
  </script>

<script src="//instant.page/1.2.2" type="module" integrity="sha384-2xV8M5griQmzyiY3CDqh1dn4z3llDVqZDqzjzcY+jCBCk/a5fXJmuZ/40JJAPeoU"></script>




  <script async src="https://cdn.jsdelivr.net/gh/xaoxuu/cdn-busuanzi@2.3/js/busuanzi.pure.mini.js"></script>




  
  
  
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-backstretch/2.0.4/jquery.backstretch.min.js"></script>
    <script type="text/javascript">
      $(function(){
        if ('') {
          $('').backstretch(
          ["/img/background.jpg"],
          {
            duration: "6000",
            fade: "2500"
          });
        } else {
          $.backstretch(
          ["/img/background.jpg"],
          {
            duration: "6000",
            fade: "2500"
          });
        }
      });
    </script>
  











  
<script src="/js/app.js"></script>



  
<script src="/js/search.js"></script>





<!-- 复制 -->
<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  let COPY_SUCCESS = "复制成功";
  let COPY_FAILURE = "复制失败";
  /*页面载入完成后，创建复制按钮*/
  !function (e, t, a) {
    /* code */
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '  <i class="fa fa-copy"></i><span>复制</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });

      clipboard.on('success', function(e) {
        //您可以加入成功提示
        console.info('Action:', e.action);
        console.info('Text:', e.text);
        console.info('Trigger:', e.trigger);
        success_prompt(COPY_SUCCESS);
        e.clearSelection();
      });
      clipboard.on('error', function(e) {
        //您可以加入失败提示
        console.error('Action:', e.action);
        console.error('Trigger:', e.trigger);
        fail_prompt(COPY_FAILURE);
      });
    }
    initCopyCode();

  }(window, document);

  /**
   * 弹出式提示框，默认1.5秒自动消失
   * @param message 提示信息
   * @param style 提示样式，有alert-success、alert-danger、alert-warning、alert-info
   * @param time 消失时间
   */
  var prompt = function (message, style, time)
  {
      style = (style === undefined) ? 'alert-success' : style;
      time = (time === undefined) ? 1500 : time*1000;
      $('<div>')
          .appendTo('body')
          .addClass('alert ' + style)
          .html(message)
          .show()
          .delay(time)
          .fadeOut();
  };

  // 成功提示
  var success_prompt = function(message, time)
  {
      prompt(message, 'alert-success', time);
  };

  // 失败提示
  var fail_prompt = function(message, time)
  {
      prompt(message, 'alert-danger', time);
  };

  // 提醒
  var warning_prompt = function(message, time)
  {
      prompt(message, 'alert-warning', time);
  };

  // 信息提示
  var info_prompt = function(message, time)
  {
      prompt(message, 'alert-info', time);
  };

</script>


<!-- fancybox -->
<script src="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js"></script>
<script>
  let LAZY_LOAD_IMAGE = "";
  $(".article-entry").find("fancybox").find("img").each(function () {
      var element = document.createElement("a");
      $(element).attr("data-fancybox", "gallery");
      $(element).attr("href", $(this).attr("src"));
      /* 图片采用懒加载处理时,
       * 一般图片标签内会有个属性名来存放图片的真实地址，比如 data-original,
       * 那么此处将原本的属性名src替换为对应属性名data-original,
       * 修改如下
       */
       if (LAZY_LOAD_IMAGE) {
         $(element).attr("href", $(this).attr("data-original"));
       }
      $(this).wrap(element);
  });
</script>





  <script>setLoadingBarProgress(100);</script>
</body>
</html>
